package com.example.testgame.sprite;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

import com.example.testgame.sys.Constant;
import com.example.testgame.sys.Variable;

public class RoleSprite extends BaseSprite {
	
	private int normalDistance;
	private int selectedDistance;
	
	public Bitmap roleAvatar;		// 角色头像
	public String roleName;			// 角色名称
	public RoleType roleType;		// 角色类型
	public int moveingPointField;	// 平原移动力
	public int moveingPointForest;	// 森林移动力
	public int moveintPointHill;	// 山地移动力
	public int moveintPointWater;	// 水中移动力
	public int curHP;				// 当前生命值
	public int maxHP;				// 最大生命值
	public int curMP;				// 当前魔法值
	public int maxMP;				// 最大魔法值
	public RoleStatus roleStatus;	// 角色状态
	
	public int col;					// 所在列
	public int row;					// 所在行
	
	private int distance;			// 离地距离
	private Rect shadowRect;
	private Rect roleRect;
	private Paint shadowPaint;
	private Paint rolePaint;
	
	public RoleSprite() {
		normalDistance = Constant.BLOCK_HEIGHT / 10;
		selectedDistance = Constant.BLOCK_HEIGHT / 5;
		shadowRect = new  Rect();
		roleRect = new Rect();
		shadowPaint = new Paint();
		shadowPaint.setARGB(160, 0, 0, 0);
		rolePaint = new Paint();
		distance = normalDistance;
	}

	@Override
	public void draw(Canvas c) {
		if(roleAvatar == null) 
			return;
		int width = (int) (Constant.BLOCK_WIDTH * Variable.zoom);
		int height = (int) (Constant.BLOCK_HEIGHT * Variable.zoom);
		int x = (int) (col * width + Variable.offsetX);
		int y = (int) (row * height + Variable.offsetY);
		roleRect.set(x, y - distance, x + width, y + height - distance);
		shadowRect.set(x, y, x + width, y + height);
		c.drawRect(shadowRect, shadowPaint);
		c.drawBitmap(roleAvatar, null, roleRect, rolePaint);
	}
	
	
	/**
	 * 角色类型
	 * @author wolf_jr
	 *
	 */
	public static enum RoleType {
		ally, enemy, neutral
	}
	
	/**
	 * 角色状态
	 * @author wolf_jr
	 *
	 */
	public static enum RoleStatus {
		normal, moved, actioned
	}

}
